package de.szut.dqi12.sqlitebrowser.view;

import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import de.szut.dqi12.sqlitebrowser.controller.Controller;
import de.szut.dqi12.sqlitebrowser.controller.GUIController;

/**
 * MyWindowListener
 * Window Listener to check when the user closed the window
 * @author Alexander
 */

public class MyWindowListener extends WindowAdapter {
	
	private GUIController GUIController;
	private Controller controller;
	
	/**
	 * Constructor
	 * gets the instances of Controller and GUIController class
	 */
	@SuppressWarnings("static-access")
	public MyWindowListener() {
		controller = Controller.getInstance();
		GUIController = GUIController.getInstance(controller.getView());
	}
	
	/**
	 * Overrides the windowClosing Methode
	 * calls method to update the frame size and position in the propertie file
	 */
	
	@Override
	public void windowClosing(WindowEvent e) {
		controller.setFrameBounds(((Component) e.getSource()).getBounds());
	}

}
